//
//  BySotreVC.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/11/6.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "BySotreVC.h"

// view
#import "ByViewStoreHeader.h"               // 店铺头视图
#import "ByViewStoreProductListTable.h"     // 列表
@interface BySotreVC ()

@property (nonatomic, strong) ZKSegmentControl *segment;
@property (nonatomic, strong) ByViewStoreHeader *header;


@end

@implementation BySotreVC

#pragma mark - view method
- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"店铺详情";
    [self addLeftBackBarButtonItem];
    [self addBYItemviews:@[@"搜索"] mode:ByNavigationItemModeImage position:ByNavigationItemPositionModeRight];
    
    [self createViews];
}


#pragma mark - 创建视图
- (void)createViews {
    
    _header = [[ByViewStoreHeader alloc] init];
    [self.view addSubview:_header];
    [_header mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(@0);
        make.height.equalTo(@120);
    }];
    
    _segment = [[ZKSegmentControl alloc] init];
    _segment.segmentSelectTint = BY_GOLD_COLOR;
    _segment.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_segment];
    _segment.segmentsArray = @[@"强力推荐", @"新品上架"];
    _segment.dynamicalAddContentViewBlock = ^ (void (^contentViewFetchBlock)(ZKSegmentContentView *contentView), NSInteger index) {
        
        ByViewStoreProductListTable *contentView = [[ByViewStoreProductListTable alloc] init];
        contentView.index = index;
        if (contentViewFetchBlock) {
            contentViewFetchBlock(contentView);
        }
    };
    [_segment mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_header.mas_bottom);
        make.left.right.equalTo(@0);
        if (@available(ios 11.0,*)) {
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
        } else {
            make.bottom.equalTo(self);
        }
    }];
}
@end
